
clear all
set more off

use "data/raw/daylight-sender-deidentified", clear 

* Classify private support
gen join = daylight_opposition=="Yes"
lab var join "Joined campaign"

* Drop pre-randomization attritters and flag post-randomization attriters
* condition: excuse or noexcuse
drop if !inlist(condition, "excuse", "noexcuse")

gen attrit = 0
replace attrit = 1 if misleading == "" 
lab var attrit "Respondent attritted post-randomization"

* Generate outcome and treatment variables
gen posted = post=="Yes"
*replace posted = 1 if missing(post)
replace posted = . if missing(post)
lab var posted "Authorized Twitter post"
drop post 

gen excuse = condition=="excuse"
lab var excuse "Excuse condition"
gen noexcuse = condition=="noexcuse"
lab var noexcuse "No excuse condition"
drop condition


gen partisan = .
replace partisan = 2 if liberal == "Very conservative"
replace partisan = 1 if liberal == "Conservative"
replace partisan = 0 if liberal == "Neither liberal nor conservative"
replace partisan = -1 if liberal == "Liberal"
replace partisan = -2 if liberal == "Very liberal"
label var partisan "Partisan leaning"
gen ind = 0

rename misleading misleading_temp
gen misleading = misleading_temp=="Yes"
drop misleading_temp

lab var misleading "Respondent found Tweet misleading"
lab var open_misleading "Reason Tweet was misleading"

destring year, replace
gen age = 2021-year
lab var age "Age"
drop year

gen age2 = age^2
lab var age2 "Age squared"
gen hisp = hispanic=="Yes"
lab var hisp "Spanish, Hispanic, or Latino"
drop hispanic
gen male = sex == "Male"
lab var male "Male"
drop sex

lab var education "Education level"

gen white = race=="Caucasian/White"
lab var white "White"
lab var race "Race"

foreach mcvar of varlist mc* {
	gen s`mcvar' = .
	replace s`mcvar'=1 if `mcvar'=="Agree"
	replace s`mcvar'=0 if `mcvar'=="Disagree"
	drop `mcvar'
	rename s`mcvar' `mcvar'
} 

gen mc_score = -(mc_1+mc_2+mc_3+mc_4-mc_5+mc_6-mc_7+mc_8-mc_9-mc_10+mc_11+mc_12+mc_13)

keep attrit join posted excuse noexcuse education race partisan age age2 hisp male white misleading open_misleading mc_score attention party

save "data/working/daylight-sender.dta", replace
exit,clear
